﻿using System;

namespace SitioINewThreadSoft.Componentes
{
    public partial class editorFecha : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            Delta_util.Clases.Utilerias.ExecScript(this.Page, "$('#" + this.txt_fecha.ClientID + "').datepicker({ changeMonth: true,changeYear: true, dateFormat: \"" + formatoJQuery + "\"});", "configurarfecha_" + this.ID);
        }

        public string formato
        {
            get
            {
                if (ViewState["formatoCS"] == null)
                    ViewState["formatoCS"] = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern;
                return (string)ViewState["formatoCS"];
            }

            set
            {
                ViewState["formatoCS"] = value;
            }
        }

        public string formatoJQuery
        {
            get
            {
                if (ViewState["formato"] == null)
                    ViewState["formato"] = "dd/mm/yy";
                return (string)ViewState["formato"];
            }

            set
            {
                ViewState["formato"] = value;
            }
        }


        public DateTime? FechaSeleccioanda
        {
            get
            {
                return Delta_util.Clases.Comun.Convertir<DateTime?>(this.txt_fecha.Text);
            }
            set
            {
                if (value == null)
                    this.txt_fecha.Text = "";
                else
                {
                    this.txt_fecha.Text = value.Value.ToString(formato);
                }
            }
        }
    }
}